#include "protocol.h"
#include "comfun.h"

#define MY_SNO (1)

int check_net_status(uint8_t data[],int len)
{
    int i=0 ;

check_net:
    while(i<len)
    {
        if(data[i] == 0x57)
            break;
        i++;
    }

    //log_d("i is %d\n",i);
    if(i>=len)
        return -1;

    //if(data[i+1] != MY_SNO && data[i+1] != 0xAA)//sno not mine
    if(data[i+1] >16 && data[i+1] != 0xAA)
    {
        log_d("sno wrong\n");
        i++;
        goto check_net;
    }

    if(data[i+2] != checksum(data+i,2))//sum wrong
    {
        log_d("check wrong\n");
        i++;
        goto check_net;
    }

    return 1;
}
